{%include file="m.index.header.tpl.php"%}
<!--头部 end-->
<!--主体部分-->
<form name="myform" method="post" action=""  enctype="multipart/form-data">
<div class="container" style="margin-top:70px;">
	<div class="row row_margin">
		
		<div class="form-group">
				<label for="" class="col-sm-2  control-label">标题：</label>
				<div class="col-sm-10 ">
					<input type="text" class="form-control" name="notice_title">
				</div>
			</div>
			<div class="form-group">
				<label for="" class="col-sm-2  control-label">发布部门：</label>
				<div class="col-sm-10 ">
					<select class="form-control" style="padding:0;" name="department_id">
						{%foreach from=$department_lists key=key item=value%}
						<option value="{%$value.department_id%}">{%$value.department_name%}</option>
						{%/foreach%}
						<option value="research" name="research">教研组</option>
						<option value="prepare" name="prepare">备课组</option>
						<option value="discipline" name="discipline">学科组</option>
						<option value="grade" name="grade">级长</option>
					</select>
				</div>	
			</div>
			<div class="form-group">
				<label for="" class="col-sm-2  control-label">发布时间：</label>
				<div class="col-sm-10 ">
					<input type="text" class="form-control" value="" id="date"  name="start_time"> 

				</div>
			</div>
			<div class="form-group">
				<label for="" class="col-sm-2  control-label">文章内容：</label>
				<div class="col-sm-10 ">
					<textarea id="category_content" name="notice_content" rows="22" cols="40" style="width: 100%"></textarea>
				</div>
			</div>
			<div class="form-group">
				<label for="" class="col-sm-2  control-label">附件：</label>
				<div class="col-sm-10 ">
					<input type="file" name="notice_file" >
				</div>
			</div>
			<div class="form-group">
						  <label for="inputPassword3" class="col-md-1 control-label" style="padding:0;">
							  阅读对象：
						  </label>
						  <div class="col-sm-1 col-xs-10">
							   <span class="btn btn-default" id="jiao">选择教师</span>
						  </div>
                          <div class="col-sm-10 col-xs-10" id="jiao1">
                                 <div class="col-sm-12">
                                   
                                 </div>
                                <div class="col-sm-10 col-sm-offset-1">
                                   <ul id="tree2" class="ztree"></ul>
                                </div>
						  </div>
                          <!--添加-->      
                   <!--添加--> 
				    </div>
                    <div style="clear:both; height:10px;"></div>
					<div class="form-group">
                          <div class="col-sm-1 col-sm-offset-1">
							   <span class="btn btn-default" id="student">选择学生</span>
						  </div>
                          <div class="col-sm-10 col-xs-10" id="student1">
                            
                                  <div class="col-sm-10 col-sm-offset-1">
                                       <ul id="treeDemo" class="ztree"></ul>
                                       <div style="display:none;">
                                            被勾选时：<input type="checkbox" id="py" class="checkbox first" checked /><span>关联父</span>
                                            <input type="checkbox" id="sy" class="checkbox first" checked /><span>关联子</span><br/>
                                            取消勾选时：<input type="checkbox" id="pn" class="checkbox first" checked /><span>关联父</span>
                                            <input type="checkbox" id="sn" class="checkbox first" checked /><span>关联子</span><br/>
                                        </div>
                                  </div>
						  </div> 
                    </div>
					
				</div><!--box-body -->
				<div id="hiddenBox"></div>
                <div class="box-footer text-center">
                    <button type="submit" class="btn btn-primary " onclick="c();"> 保 存</button>
                </div>
             </form>
           </div><!--box box-default box-solid-->
        </div><!--row-->
 </div>
  <!--主要内容结束-->
{%include file="m.index.footer.tpl.php"%}
<script>
 $(function() {
	 $( "#date" ).datetimepicker({
	  timeFormat: "HH:mm",
      showOtherMonths: true,
      selectOtherMonths: true,
	  changeMonth: true,
      changeYear: true,   
    });
 })
</script>
<script src="static/js/jquery.ztree.core.js"></script><!--树形-->
<script src="static/js/jquery.ztree.excheck.js"></script><!--树形-->
<script>
 $(function() {
	$("#student1").hide();	
	$("#jiao1").hide();
    $("#student").click(function(){
		 $("#student1").toggle();			
		});
    $("#jiao").click(function(){
		 $("#jiao1").toggle();			
		});
    })
</script>
<script type="text/javascript" src="static/xhe/xheditor-1.2.2.min.js"></script>
<script type="text/javascript" src="static/xhe/xheditor_lang/zh-cn.js"></script>
<script type="text/javascript">
$(pageInit);
function pageInit()
{
	$.extend(XHEDITOR.settings,{shortcuts:{'ctrl+enter':submitForm}});//修改默认设置
	$('#category_content').xheditor({modalWidth:700,modalHeight:500,upBtnText:'浏览',upLinkUrl:"!ckfinder/upload.html",upImgUrl:"!ckfinder/upload.html?type=Images",upFlashUrl:"!ckfinder/upload.html?type=Flash",upMediaUrl:"!ckfinder/upload.html"});
}
function submitForm(){$('#myform').submit();}
</script>


<script>
     var setting = {
            check: {
                enable: true
            },
            view:{
                showIcon:false
            },
              
            data: {
                simpleData: {
                    enable: true
                }
            }
        };
        var ztNodes =[
		    { id:"g0", pId:0, name:"全体教师"},
			{ id:"g1", pId:"g0", name:"部门"},
			{%foreach from=$department_lists key=key item=value%}
				{ id:"bm_{%$value.department_id%}", pId:"g1", name:"{%$value.department_name%}", },
			{%/foreach%}			
			{%foreach from=$department_name key=key item=value%}
				{ id:"user_{%$value.user_id%}", pId:"bm_{%$value.department_id%}", name:"{%$value.staff_name%}", },
			{%/foreach%}
			{ id:"g2", pId:"g0", name:"教研组"},
			{%foreach from=$research_lists key=key item=value%}
				{ id:"xka_{%$value.research_id%}", pId:"g2", name:"{%$value.research_name%}", },
			{%/foreach%}
			{%foreach from=$research_name key=key item=value%}
				{ id:"user_{%$value.user_id%}", pId:"xka_{%$value.research_id%}", name:"{%$value.staff_name%}", },
			{%/foreach%}
			{ id:"g3", pId:"g0", name:"备课组"},
			{%foreach from=$prepare_lists key=key item=value%}
				{ id:"xkb_{%$value.prepare_id%}", pId:"g3", name:"{%$value.prepare_name%}", },
			{%/foreach%}
			{%foreach from=$prepare_name key=key item=value%}
				{ id:"user_{%$value.user_id%}", pId:"xkb_{%$value.prepare_id%}", name:"{%$value.staff_name%}", },
			{%/foreach%}
			{ id:"g4", pId:"g0", name:"学科组"},
			{%foreach from=$discipline_lists key=key item=value%}
				{ id:"xkc_{%$value.discipline_id%}", pId:"g4", name:"{%$value.discipline_name%}", },
			{%/foreach%}
			{%foreach from=$discipline_name key=key item=value%}
				{ id:"user_{%$value.user_id%}", pId:"xkc_{%$value.discipline_id%}", name:"{%$value.staff_name%}", },
			{%/foreach%}
			
];
        var ztcode;
        function setCheck1() {
            var zTree = $.fn.zTree.getZTreeObj("tree2"),
            py = $("#py").attr("checked")? "p":"",
            sy = $("#sy").attr("checked")? "s":"",
            pn = $("#pn").attr("checked")? "p":"",
            sn = $("#sn").attr("checked")? "s":"",
            type = { "Y":py + sy, "N":pn + sn};
            zTree.setting.check.chkboxType = type;
            showCode('setting.check.chkboxType = { "Y" : "' + type.Y + '", "N" : "' + type.N + '" };');
        }
        function showCode1(str) {
            if (!ztcode) ztcode = $("#ztcode");
            ztcode.empty();
            ztcode.append("<li>"+str+"</li>");
        }
        $(document).ready(function(){
            $.fn.zTree.init($("#tree2"), setting, ztNodes);
            setCheck1();
            $("#py").bind("change", setCheck1);
            $("#sy").bind("change", setCheck1);
            $("#pn").bind("change", setCheck1);
            $("#sn").bind("change", setCheck1);
        });
</script>


<script type="text/javascript">
		var setting = {
			check: {
				enable: true,	
			},
			data: {
				simpleData: {
					enable: true
				}
			}
		};
		var zNodes =[
		{ id:"b0", pId:0, name:"全体学生", },
		{%foreach from=$grade_lists key=key item=value%}
			{ id:"g_{%$key%}", pId:"b0", name:"{%$value%}", open:true},
		{%/foreach%}
		{%foreach from=$class_lists key=key item=value%}
			{ id:"c_{%$value.class_id%}", pId:"g_{%$value.grade_id%}", name:"{%$value.class_name%}", open:true},
		{%/foreach%}
		{%foreach from=$student_lists key=key item=value%}
			{ id:"user_{%$value.user_id%}", pId:"c_{%$value.class_id%}", name:"{%$value.student_name%}", {%if $value.is_check=='1'%}checked:true,{%/if%} open:true, last:true},
		{%/foreach%}
		];
		var code;
		
		function setCheck() {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
			py = $("#py").attr("checked")? "p":"",
			sy = $("#sy").attr("checked")? "s":"",
			pn = $("#pn").attr("checked")? "p":"",
			sn = $("#sn").attr("checked")? "s":"",
			type = { "Y":py + sy, "N":pn + sn};
			zTree.setting.check.chkboxType = type;
			showCode('setting.check.chkboxType = { "Y" : "' + type.Y + '", "N" : "' + type.N + '" };');
		}
		function showCode(str) {
			if (!code) code = $("#code");
			code.empty();
			code.append("<li>"+str+"</li>");
		}
		$(document).ready(function(){
			$.fn.zTree.init($("#treeDemo"), setting, zNodes);
			setCheck();
			$("#py").bind("change", setCheck);
			$("#sy").bind("change", setCheck);
			$("#pn").bind("change", setCheck);
			$("#sn").bind("change", setCheck);
		});
function c()
{
	var delidID = "";
	var zTree = $.fn.zTree.getZTreeObj("treeDemo").getCheckedNodes(true);//获取所有选中状态的节点  
	for (var i = 0; i < zTree.length; i++) {  
		//delidID += zTree[i].id + ",";
		$("#hiddenBox").append('<input type="hidden" name="pid[]" value="'+zTree[i].id+'">');
	}
	var zTree = $.fn.zTree.getZTreeObj("tree2").getCheckedNodes(true);//获取所有选中状态的节点  
	for (var i = 0; i < zTree.length; i++) {  
		//delidID += zTree[i].id + ",";
		$("#hiddenBox").append('<input type="hidden" name="pid[]" value="'+zTree[i].id+'">');
	}
} 		
</script>
